<template>
    <div>
        <el-header style="text-align: right; font-size: 15px">
            <span >
                修改成绩
            </span>
        </el-header>
        <el-form :data="formLabelAlign" style="margin-top:25px" :ref="formLabelAlign" :label-position="labelPosition" label-width="80px" label-position="50%" >

            <el-form-item label="姓名">
                <el-input v-model="formLabelAlign.s_name" readonly></el-input>
            </el-form-item>
            <el-form-item label="课程号">
                <el-input v-model="formLabelAlign.c_id" readonly></el-input>
            </el-form-item>
            <el-form-item label="课程名">
                <el-input v-model="formLabelAlign.c_name" readonly></el-input>
            </el-form-item>
            <el-form-item label="分数">
                <el-input v-model="formLabelAlign.score" ></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm('formLabelAlign')">确认修改/登记</el-button>
                <el-button type="primary" @click="resetForm('formLabelAlign')">重置</el-button>
                <el-button type="primary" @click="backForm('formLabelAlign')">返回</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                labelPosition: 'top',
                formLabelAlign: {
                    s_id: this.$route.query.s_id,
                    s_name: this.$route.query.s_name,
                    c_id: this.$route.query.c_id,
                    c_name: this.$route.query.c_name,
                    score: this.$route.query.score,
                    c_credit: this.$route.query.c_credit

                }
            };
        },

        methods: {
            submitForm(formName) {
                const _this=this
                axios.post('http://localhost:8181/score/save',this.formLabelAlign).then(function (resp) {
                    if(resp.data =='success'){
                        _this.$message({
                            message: '修改/登记成功！',
                            type: 'success'
                        })
                    }
                })
            },
            backForm(formName) {
                this.$router.push({
                    path: '/Page6',
                    query:{
                        id:this.$route.query.s_id
                    }
                })
            },
            resetForm(formName){
                const _this = this
                axios.get('http://localhost:8181/score/findById/'+this.$route.query.id).then(function (resp) {
                    _this.tableData = resp.data
                })
            }
        }
    }

</script>